// run: $exec < input
#include <iostream>

int const maxn = 2000;
int a[maxn][maxn];
int n, m;

int main()
{
	std::ios::sync_with_stdio(false);
	while (std::cin >> n >> m) {
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= m; j++) std::cin >> a[i][j];
		for (int j = m; j >= 1; j--) {
			for (int i = 1; i <= n; i++)
				std::cout << a[i][j] << " ";
			std::cout << "\n";
		}
	}
}

